<?php
header("Content-type:text/html;charset=utf-8");
$mysql = mysqli_connect("localhost","root","root","test");
if($_SERVER['REQUEST_METHOD'] == "POST"){

  $id = $_POST['id'];
  $username = $_POST['username'];
  $password = $_POST['password'];
  $name = $_POST['name'];

  if($username == ""){echo "<script>alert('用户名是必填的!');history.go(-1)</script>";}
  if($username == "admin"){echo "<scirpt>alert('用户名非法!');history.go(-1)</script>";}
  if($password == ""){echo "<script>alert('密码是必填的!');history.go(-1)</script>";}
  if($name == ""){echo "<script>alert('密码是必填的!');history.go(-1)</script>";}
  $update = mysqli_query($mysql,"UPDATE user SET username = $username,password = $password,name = $name WHERE id = $id");
  if($update){
    echo "<script>alert('修改成功!');window.location.href='edit/edit.php?id=$id'</script>";
  }else{
    echo "Error" .$update ."<br/>".mysqli_error($mysql);
  }
  mysqli_close($mysql);
}
 ?>
